import http from '../util/request.js'
import {method} from "lodash";
export default {
    add:(obj)=>{
        return http({
            url:'/api/user/add',
            method:'post',
            data:obj,
            headers: {
                //定义将数据以json的形式传入后台(java)
                'Content-Type': 'application/json'
            }
        });
    },
    edit:(obj)=>{
        return http({
            url:'/api/user',
            method:'put',
            data:obj,
            headers: {
                'Content-Type': 'application/json'
            }
        });
    },
    del:(id)=>{
        return http({
            url:'/api/user/'+id,
            method:'delete'
        });
    },
    delete:(id)=>{
        return http({
            url:'/api/user/del/'+id,
            method:'delete'
        });
    },
    //传表单参数
    page:(obj)=>{
        return http({
            url:'/api/user/page',
            method:'get',
            params:obj
        });
    },
    one:(id)=>{
        return http({
            url:'api/user/info/'+id,
            method:'get'
        })
    },
    validatePassword: (id,password) => {
        return http({
            url: '/api/user/validatePassword/'+id+'/'+password,
            method: 'post',
            // data: data,
            // headers: {
            //     'Content-Type': 'application/json'
            // }
        });
    },
    register:(data)=>{
        return http({
            url:'/api/user/register',
            method: 'post',
            data: data,
            headers: {
                'Content-Type': 'application/json'
            }
        })
    },

    // 发送邮箱验证码
    sendEmailCode: (data) => {
        return http({
            url: '/api/user/sendEmailCode',
            method: 'post',
            data: data,
            headers: {
                'Content-Type': 'application/json'
            }
        });
    },

    // 通过邮箱验证码重置密码
    resetPasswordByEmail: (data) => {
        return http({
            url: '/api/user/resetPasswordByEmail',
            method: 'post',
            data: data,
            headers: {
                'Content-Type': 'application/json'
            }
        });
    }

}